package funjava;

/**
 * Created by judasnow on 5/31/16.
 */

class FooBar {
    public static int x = 0;
	public static void x1() {
		System.out.print(1);
	}
	public static void x1(int x) {
		System.out.print(x);
	}
}

class BarBaz extends FooBar {
    public static int x = 4;
}

class Ref {
	private int x;
	public Ref(int x) {
		this.x = x;
	}
	public void setX(int x) {
		this.x = x;
	}
	public int getX() {
		return x;
	}
}

public class Fun {
	private static void changeInt(int x) {
		x = 3;
	}
	
	private static void changeX(Ref r) {
		r.setX(2);
		System.out.print(r.getX());
	}
	
    public static void main(String[] args) {
		Ref r1 = new Ref(1);
		// 对于引用类型的对象 作为参数进行传低的时候
		// 仍然是值传递，因为 java 本没有引用类型的变量
		// 因此需要区分的问题在于：java 中没有引用类型的变量，但是有引用类型的值
		System.out.println(r1.getX());
		Fun.changeX(r1);
		System.out.println(r1.getX());
		
		int x = 1;
		System.out.println(x);
		Fun.changeInt(x);
		System.out.println(x);
    }
}
